package test;

import javax.swing.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class MyJFram02 extends JFrame implements MouseListener {
        public MyJFram02(){
        this.setSize(600,500);
        this.setAlwaysOnTop(true);
        this.setDefaultCloseOperation(3);
        this.setLayout(null);
        this.setLayout(null);
        this.setLocationRelativeTo(null);

        //设置鼠标监听事件
        JButton jbt = new JButton("请点击");
        jbt.setBounds(0,0,200,200);
        jbt.addMouseListener(this);
        this.getContentPane().add(jbt);
        this.setVisible(true);
    }


    @Override
    public void mouseClicked(MouseEvent e) {
        System.out.println("鼠标点击");
    }

    @Override
    public void mousePressed(MouseEvent e) {
        System.out.println("鼠标按压");
    }

    @Override
    public void mouseReleased(MouseEvent e) {
        System.out.println("鼠标释放");
    }

    @Override
    public void mouseEntered(MouseEvent e) {
        System.out.println("鼠标划入");
    }

    @Override
    public void mouseExited(MouseEvent e) {
        System.out.println("鼠标划出");
    }
}
